﻿using System;

namespace RaytracerLib.Resamplers.Filters
{
    public class TriangleFilter : Filter
    {
        public override string Name
        {
            get
            {
                return "Triangle";
            }
        }

        public TriangleFilter()
            : base(1)
        { 
        }

        public override FilterType FilterType
        {
            get
            {
                return FilterType.Triangle;
            }
        }

        public override double Evaluate(double a_value)
        {
            double v = Math.Abs(a_value);

            if (v > 1)
                return 0;

            return 1 - v;
        }

        public override string ToString()
        {
            return "Triangle";
        }
    }
}